package com.lipengcheng.search.pojo;


import com.lipengcheng.feign.common.dto.Item;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
public class ItemDOC {
    private Long id;//商品id1
    private String name;//商品名称1
    private Long price;//价格（分）1
    private String image;//商品图片1
    private String category;//分类名称1
    private String brand;//品牌名称1
    private Integer sold;//销量1
    private Integer commentCount;//评论数1
    private Boolean isAD;//商品状态 1-正常，2-下架
    private List<String> suggestion = new ArrayList<>(2);

    //把从数据查出来的参数复制到这个es的实体类
    public ItemDOC(Item item) {
        //复制属性
        BeanUtils.copyProperties(item,this);
        //自动补全字段
        //品牌
        suggestion.add(item.getBrand());
        //分类
        suggestion.add(item.getCategory());

    }


}

